package leetcode.题库;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;


public class Test {

    static int a = 1;

    public static void main(String[] args) {

        List<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(2);
        ArrayList<Integer> list1 = new ArrayList<>();
        list1.add(2);
        list1.add(3);
        Set<Integer> set = new HashSet<>(list1);
        list = list.stream().filter(num->set.contains(num)).collect(Collectors.toList());
        for (int num:list) {
            System.out.println(num);
        }
    }

}
